package cn.edu.cqvie.jdk8.method;

import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.function.Function;
import java.util.function.Supplier;

public class MethodReferenceTest {

    public String getString(Supplier<String> supplier) {
        return supplier.get() +  "test";
    }

    public String getString2(String str, Function<String, String> function) {
        return function.apply(str);
    }

    public static void main(String[] args) {
        Student student1 = new Student("zhangsan" ,10);
        Student student2 = new Student("lisi" ,90);
        Student student3 = new Student("wangwu" ,50);
        Student student4 = new Student("zhaoliu" ,20);

        List<Student> students = Arrays.asList(student1, student2, student3, student4);
//        students.sort((s1, s2) -> Student.compareStudentByScore(s1, s2));
//        students.forEach(item -> System.out.println(item));

//        students.sort(Student::compareStudentByScore);
//        students.forEach(System.out::println);

//        students.sort((s1, s2) -> Student.compareStudentByScore(s1, s2));
//        students.forEach(item -> System.out.println(item.getScore()));


//        StudentComparator studentComparator = new StudentComparator();
//        students.sort(studentComparator::compareStudentByScore);
//        students.forEach(System.out::println);

//        students.sort(Student::compareByScore);
//        students.forEach(System.out::println);

//        List<String> cities = Arrays.asList("qiaodao", "chongqing", "tianjing", "beijing");
//        Collections.sort(cities, (city1, city2) -> city1.compareToIgnoreCase(city2));
//        cities.forEach(System.out::println);
//        Collections.sort(cities, String::compareToIgnoreCase);
//        cities.forEach(System.out::println);

        MethodReferenceTest methodReferenceTest = new MethodReferenceTest();
//        System.out.println(methodReferenceTest.getString(String::new));

        System.out.println(methodReferenceTest.getString2("hello", String::new));
    }


}
